
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _STATEMENT_H_
#define _STATEMENT_H_

// A statement is a single executable piece of javascript
// which knows how to execute itself given the proper 
// execution environment, which we call a "Scope".

// Every Statement has associated with it a (possible empty) set of
// labels.
#define GC_THREADS
//#include <gc_allocator.h>
//#include <gc_cpp.h>
#include <set>
#include <vector>

#include "String.h"

class Scope;
class Value;

class Statement  
{
public:
    Statement();

    Value* execute(Scope* scope) const;
    virtual Value* execute_internal(Scope* scope) const = 0;

    // Add to ids the list of Variable declarations contained in your statement
    // Statement's implementation of this is to do nothing
    virtual void getDeclaredVariables(std::vector<String*>& ids) const;

    bool hasLabel(String* target) const;
    void addLabel(String* id);

    void setLineNumber(int line);
    int getLineNumber() const;

private:
    std::set<String*, ltstring> m_labels;
    int m_line_number;
};

#endif//_STATEMENT_H_

